package com.ydsungan.daoimpl;

import com.ydsungan.bean.Clockin;
import com.ydsungan.dao.ClockinDao;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;
import java.util.Map;

public class ClockinDaoImpl implements ClockinDao {

    SqlSessionFactory sqlSessionFactory = null;
    public ClockinDaoImpl(SqlSessionFactory sqlSessionFactory) {
        this.sqlSessionFactory = sqlSessionFactory;

    }

    @Override
    public List<Clockin> findClockinByMap(Map<String, Object> map) {
        SqlSession sqlSession = sqlSessionFactory.openSession();

        List<Clockin> list = sqlSession.selectList("getClockinByMap", map);
        sqlSession.close();
        return list;
    }

    @Override
    public void addClockin(Clockin clockin) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        sqlSession.insert("addClockin", clockin);
        sqlSession.commit();
        sqlSession.close();

    }
}
